home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_001 / balls / bres.c < prev    next >
Text File  |  1992-05-06  |  754b  |  40 lines

  1. /*
  2. ** b r e s . c
  3. **
  4. ** perry s. kivolowitz - ihnp4!ptsfa!well!perry
  5. **
  6. ** not to be distritbuted for commercial use. any distribution
  7. ** must included this notice, please.
  8. **
  9. ** generate radial  displacements according to bresenham's circle
  10. ** algorithm. suitable for running twice, giving a fast spherical
  11. ** surface.
  12. **
  13. */
  14.  
  15. bres(r , array)
  16. register short *array;
  17. register r;
  18. {
  19.    register x , y , d;
  20.  
  21.    x = 0;
  22.    y = r;
  23.    d = 3 - 2 * r;
  24.    while (x < y) {
  25.       *(array + r - y) = x;
  26.       *(array + r - x) = y;
  27.       *(array + r + y - 1) = x;
  28.       *(array + r + x - 1) = y;
  29.       if (d < 0) d += 4 * x + 6;
  30.       else d += 4 * (x - y--) + 10;
  31.       x++;
  32.    }
  33.    if (x == y) {
  34.       *(array + r - y) = x;
  35.       *(array + r + y - 1) = x;
  36.    }
  37. }
  38.  
  39.  
  40.